//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml
{
    internal class ReColorInfo : ShapeElement
    {
        internal const string xmlName = "recolorinfo";
        private List<ReColorInfoEntry> _entries = new List<ReColorInfoEntry>();
        private string numcolors;
        private string recolorstate;
        //recolorstate="t" numcolors="1"
        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read(VmlConstants.PowerpointNamespace + xmlName))
            {
                recolorstate = c.GetOptionalString("recolorstate");
                numcolors = c.GetOptionalString("numcolors");
                _entries.Clear();
                _entries.AddRange(c.ReadOptionalWhile<ReColorInfoEntry>(ReColorInfoEntry.xmlName));
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (var c = context.Write(VmlConstants.PowerpointNamespace + xmlName))
            {
                c.SetOptionalString("recolorstate", recolorstate );
                c.SetOptionalString("numcolors", numcolors );
                c.WriteElements(_entries);
            }
        }
    }
}